#include <linux/kernel.h>
#include <asm/hypervisor.h>
#include <linux/fs.h>
+#include <linux/blk.h>
#include <linux/slab.h>
#include <linux/genhd.h>
#include <asm/hypervisor-ifs/block.h>
int first_part_minor)
{
physdisk_probebuf_t *buf;
- int i;
- int minor;
- int count;
+ int i, minor;
- buf = kmalloc(sizeof(*buf), GFP_KERNEL);
- if (!buf)
+ /* Privileged domains can read partition info themselves. */
+ if (start_info.flags & SIF_PRIVILEGED)
+ return 0;
+
+ /* This only deals with raw/direct devices (IDE & SCSI). */
+ switch ( xldev_to_physdev(bdev->bd_dev) & XENDEV_TYPE_MASK )
+ {
+ case XENDEV_IDE:
+ case XENDEV_SCSI:
+ break;
+ default:
+ return 0;
+ }
+
+ if ( (buf = kmalloc(sizeof(*buf), GFP_KERNEL)) == NULL )
return -ENOMEM;
+
buf->domain = start_info.dom_id;
buf->start_ind = 0;
buf->n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
xenolinux_control_msg(XEN_BLOCK_PHYSDEV_PROBE, (char *)buf,
sizeof(*buf));
- if (buf->n_aces == 0) {
- kfree(buf);
- return 0;
- }
- if (buf->n_aces == PHYSDISK_MAX_ACES_PER_REQUEST) {
- kfree(buf);
- return 0;
- }
-
- count = 0;
+ if ( buf->n_aces == PHYSDISK_MAX_ACES_PER_REQUEST )
+ printk(KERN_ALERT "Too many returns for xeno partition parser\n");
- for (i = 0; i < buf->n_aces; i++) {
- if (buf->entries[i].partition == 0) {
+ for ( i = 0; i < buf->n_aces; i++ )
+ {
+ if (buf->entries[i].partition == 0)
continue;
- }
- /* Make sure the partition is actually supposed to be on this
- disk. */
- if (buf->entries[i].device != xldev_to_physdev(bdev->bd_dev)) {
+ if (buf->entries[i].device != xldev_to_physdev(bdev->bd_dev))
continue;
- }
- /* This is a bit of a hack - the partition numbers are
- specified by the hypervisor, and if we want them to match
- up, this is what we need to do. */
- count ++;
+ if (!(buf->entries[i].mode & PHYSDISK_MODE_W))
+ {
+ if (!(buf->entries[i].mode & PHYSDISK_MODE_R))
+ continue;
+ set_device_ro(bdev->bd_dev, 1);
+ }
minor = buf->entries[i].partition + first_part_minor - 1;
add_gd_partition(hd,
minor,
buf->entries[i].start_sect,
buf->entries[i].n_sectors);
}
- kfree(buf);
- /* If we didn't find any suitable Xeno partitions, try the other
- types. */
- if (!count)
- return 0;
+ kfree(buf);
printk("\n");
+
return 1;
}